package org.desktop.web.shared.domain.entities;

import java.io.Serializable;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import java.util.List;


/**
 * The persistent class for the PROJECTS database table.
 * 
 */
@Entity
@Table(name="PROJECTS")
@NamedQuery(name="Project.findAll", query="SELECT p FROM Project p")
@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonIgnoreProperties(value={"subProjects","timesheets"})
@JsonInclude(Include.NON_NULL)
public class Project implements Serializable, com.google.gwt.user.client.rpc.IsSerializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private String descProject;
	private List<SubProject> subProjects;
	private List<Timesheet> timesheets;

	public Project() {
	}


	@Id
	@Column(unique=true, nullable=false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Column(name="DESC_PROJECT", length=45)
	public String getDescProject() {
		return this.descProject;
	}

	public void setDescProject(String descProject) {
		this.descProject = descProject;
	}


	//bi-directional many-to-one association to SubProject
	@OneToMany(mappedBy="project")
	public List<SubProject> getSubProjects() {
		return this.subProjects;
	}

	public void setSubProjects(List<SubProject> subProjects) {
		this.subProjects = subProjects;
	}

	public SubProject addSubProject(SubProject subProject) {
		getSubProjects().add(subProject);
		subProject.setProject(this);

		return subProject;
	}

	public SubProject removeSubProject(SubProject subProject) {
		getSubProjects().remove(subProject);
		subProject.setProject(null);

		return subProject;
	}


	//bi-directional many-to-one association to Timesheet
	@OneToMany(mappedBy="project")
	public List<Timesheet> getTimesheets() {
		return this.timesheets;
	}

	public void setTimesheets(List<Timesheet> timesheets) {
		this.timesheets = timesheets;
	}

	public Timesheet addTimesheet(Timesheet timesheet) {
		getTimesheets().add(timesheet);
		timesheet.setProject(this);

		return timesheet;
	}

	public Timesheet removeTimesheet(Timesheet timesheet) {
		getTimesheets().remove(timesheet);
		timesheet.setProject(null);

		return timesheet;
	}

}